<?php if ( ! defined('BASEPATH')) exit('This file does not run directly. Sorry.'); ?>
<?php
/**
 * Kalaisoo.
 *
 * A lightweight no-framework framework written in PHP.
 *
 * @package Kalaisoo
 * @author $Author: info@sah-company.com $
 * @version $Id: geoip.php 126 2012-01-11 20:59:15Z info@sah-company.com $
 */

/**
 * Load third party "GeoIP" vendor code.
 *
 * This product includes GeoLite data created by MaxMind, available from
 * http://www.maxmind.com/.
 *
 * @see http://www.maxmind.com
 */
include BASEPATH.'/vendor/geoip/geoipcity.inc';
include BASEPATH.'/vendor/geoip/geoipregionvars.php';

/**
 * Kalaisoo GeoIPFacade Class.
 *
 * @package Kalaisoo
 * @subpackage System
 * @author $Author: info@sah-company.com $
 */
class GeoIPFacade
{
	/**
	 * returns an object with geo information or false if no object was found.
	 *
	 * @param string $ipAddress
	 */
	static public function locate($ipAddress)
	{
		$gi = geoip_open(BASEPATH.'/vendor/geoip/GeoLiteCity.dat', GEOIP_STANDARD);
		return $record = geoip_record_by_addr($gi, $ipAddress);
	}
}
?>